package com.gqj.elec.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gqj.common.annotation.Log;
import com.gqj.common.core.controller.BaseController;
import com.gqj.common.core.domain.AjaxResult;
import com.gqj.common.enums.BusinessType;
import com.gqj.elec.domain.ElecMaterialCheck;
import com.gqj.elec.service.IElecMaterialCheckService;
import com.gqj.common.utils.poi.ExcelUtil;
import com.gqj.common.core.page.TableDataInfo;

/**
 * 资产盘点主Controller
 * 
 * @author lxq
 * @date 2023-12-17
 */
@RestController
@RequestMapping("/elec/elecMaterialCheck")
public class ElecMaterialCheckController extends BaseController
{
    @Autowired
    private IElecMaterialCheckService elecMaterialCheckService;

    /**
     * 查询资产盘点主列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheck:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElecMaterialCheck elecMaterialCheck)
    {
        startPage();
        List<ElecMaterialCheck> list = elecMaterialCheckService.selectElecMaterialCheckList(elecMaterialCheck);
        return getDataTable(list);
    }

    /**
     * 导出资产盘点主列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheck:export')")
    @Log(title = "资产盘点主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElecMaterialCheck elecMaterialCheck)
    {
        List<ElecMaterialCheck> list = elecMaterialCheckService.selectElecMaterialCheckList(elecMaterialCheck);
        ExcelUtil<ElecMaterialCheck> util = new ExcelUtil<ElecMaterialCheck>(ElecMaterialCheck.class);
        util.exportExcel(response, list, "资产盘点主数据");
    }

    /**
     * 获取资产盘点主详细信息
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheck:query')")
    @GetMapping(value = "/{checkId}")
    public AjaxResult getInfo(@PathVariable("checkId") Long checkId)
    {
        return AjaxResult.success(elecMaterialCheckService.selectElecMaterialCheckByCheckId(checkId));
    }

    /**
     * 新增资产盘点主
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheck:add')")
    @Log(title = "资产盘点主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElecMaterialCheck elecMaterialCheck)
    {
        return toAjax(elecMaterialCheckService.insertElecMaterialCheck(elecMaterialCheck));
    }

    /**
     * 修改资产盘点主
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheck:edit')")
    @Log(title = "资产盘点主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElecMaterialCheck elecMaterialCheck)
    {
        return toAjax(elecMaterialCheckService.updateElecMaterialCheck(elecMaterialCheck));
    }

    /**
     * 删除资产盘点主
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheck:remove')")
    @Log(title = "资产盘点主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkIds}")
    public AjaxResult remove(@PathVariable Long[] checkIds)
    {
        return toAjax(elecMaterialCheckService.deleteElecMaterialCheckByCheckIds(checkIds));
    }
}
